package com.chinabank.service;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chinabank.dao.PermissionDao;
import com.chinabank.model.Group;
import com.chinabank.model.Permission;


@Service(value = "permissionService")
public class PermissionService{
	
	private PermissionDao permissionDao;

	public PermissionDao getPermissionDao() {
		return permissionDao;
	}

	@Resource
	public void setPermissionDao(PermissionDao permissionDao) {
		this.permissionDao = permissionDao;
	}

	@Transactional
	public void addPermission(Permission p) {
		permissionDao.add(p);
	}

	@Transactional
	public void delPermission(Permission p) {
		permissionDao.delete(p);
	}

	@Transactional
	public void updatePermission(Permission p) {
		permissionDao.update(p);
	}

	@Transactional
	public Permission getPermission(Serializable id) {
		return permissionDao.get(Permission.class, id);
	}

	@Transactional
	public List<Permission> getPermissions() {
		return permissionDao.getPermissions();
	}

	@Transactional
	public List<Permission> getPermissions(Group gp) {
		// TODO Auto-generated method stub
		return null;
	}

	@Transactional
	public void addPermission(String url) {
		Permission p = new Permission(url);
		permissionDao.add(p);
		
	}
}
